<?php
/**
 * @fileoverview    取消关注接口
* @author          zhanglei11
* @date            Thu Jan 05 14:34:25 CST 2012
* @copyright       sina meila
*/

include_once '../../__global.php';
include_once(SERVER_ROOT_PATH.'/include/config/ml_3rdType_config.php');
class aj_delFollow extends ml_controller{
    
    private $follow_uid;
    
    
    function initParam() {
        $this->follow_uid = $this->input('uid','P');       //要取消关注用户uid        
                
    }
    
    function main() {
    
        $uid = $this->__visitor['uid'];            //当前登录用户uid
        
        
        $oFollow = new ml_model_dbFollow();
        $oFans = new ml_model_dbFans();
        
        $rs = $oFollow->delFollow($uid, $this->follow_uid);
        
        $rs = $oFans->delFans($this->follow_uid, $uid);
        
        //减少redis    关注数
        $this->oRedis = new ml_model_rdsCount();
        $followCnt = $this->oRedis->getFollowCnt($uid);    
        $fansCnt = $this->oRedis->getFansCnt($this->follow_uid);
        //    减少关注数
        if($followCnt > 0) 
            $followCnt = $this->oRedis->decrFollowCnt($uid);
        //    减少粉丝数
        if($fansCnt > 0)
            $followCnt = $this->oRedis->decrFansCnt($this->follow_uid);
        
        $oRdsE = new ml_model_rdsExtFollow();
        $re = $oRdsE->is_3rd($this->follow_uid, TRD_TYPE_ID_SINA);
        if ($re) {
            $oRdsE->rpush_new_extFollow($uid, $this->follow_uid, TRD_TYPE_ID_SINA);
        }
            
            
        
        //更新 粉丝数  和  关注数
        
        if($rs) { //  成功
            ml_tool_actionlog::del_follow($this->__visitor['uid'] , $this->follow_uid);
            ml_tool_sendMq::del_atnick_follow($this->__visitor['uid'] , $this->follow_uid);
            $this->api_output(ML_RCODE_SUCC);
        }else {   //  修改密码失败
            $this->api_output(ML_RCODE_FAIL);
        }
    }
    
    
    
    function checkParam(){
        $this->check_referer();
        if (!isset($this->__visitor['uid'])) {
            $this->api_output(ML_RCODE_FAIL);
        }
        
    
    }
}

new aj_delFollow();

